package com.pine.dcts.model;


import com.pine.dcts.entity.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author xiaoyuan
 * @create 2020/11/11 15:40
 **/
@Setter
@Getter
public class OrgDTO extends BaseEntity implements ITreeEntity<OrgDTO> {
    private Integer id;

    private String name;

    private Integer parentId;

    private List<OrgDTO> children;

    private List<DatasourceDTO> datasources;


    public List<Object> getTChildren() {
        return CollectionUtils.isEmpty(children)? Arrays.asList(datasources.toArray()) : Arrays.asList(children.toArray()) ;
    }
}
